require 'gameclient'
require 'gameserver'
local config = require 'config'

local server = nil
local client = nil

function love.load()
  love.graphics.setCaption('Gravit T')
  
  if config.mode == 'server' then
    server = GameServer(config.server.port)
    server:planetNew(config.server.planets)
    for k,v in pairs(config.server.ai) do
      server:aiNew(v)
    end
  else
  end
  client = GameClient(server, config.client.playerID, config.client.serverIP, config.client.serverPort)
end

function love.update(dt)
  client:update(dt)
  if server then
    server:updateState(dt)
  end
end

function love.draw()
  client:draw()
end
